﻿using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using MovieDB.DTOs;

namespace MovieDB.Mapping.CustomConverter
{
    internal class AudioQualityStringResolver : ValueResolver<MovieDto, string>
    {
        protected override string ResolveCore(MovieDto source)
        {
            IList<AudioQualityDto> audioQualities = source.AudioQualities;
            if (source.AudioQualities == null)
            {
                return string.Empty;
            }

            var audioQualitiesAsStrings = audioQualities.Select(audioQuality => audioQuality.ToString()).ToList();

            return string.Join(" / ", audioQualitiesAsStrings);
        }
    }
}